#include "app_runner.h"
#include <stdlib.h>
#include "app_bt.h"
#include "signal.h"

static int is_running = 1;

static void sig_handler(int signum) {
    is_running = 0;
}

int app_runner_run(void){
    //注册终止信号
    signal(SIGINT, sig_handler);
    signal(SIGTERM, sig_handler);
    //初始化设备
    device_t *device = app_device_init(DEVICE_FILE);
    //初始化蓝牙
    app_bt_init(device);
    //运行
    app_device_start();
    //等待终止信号
    while(is_running){
        sleep(1);
    }
    //释放资源
    app_device_destroy();
}
